package com.s7.recycler.adapter;

import android.view.View;
import android.view.ViewGroup;

import androidx.annotation.NonNull;

import com.s7.recycler.holder.BaseViewHolder;

/**
 * 多样式布局
 * @param <T>
 */
public abstract class MultiStyleAdapter<T> extends SRecyclerAdapter<T, BaseViewHolder> {

    /**
     * 获取子 item
     * @return
     */
    protected abstract int getLayoutId(int viewType);

    /**
     * 绑定数据
     * @param holder 具体的viewHolder
     * @param data   当前Item的数据
     */
    protected abstract void bindData(BaseViewHolder holder, int position, T data);

    @NonNull
    @Override
    protected BaseViewHolder getViewHolder(@NonNull ViewGroup parent, int viewType) {
        View view = getView(parent, getLayoutId(viewType));
        return new BaseViewHolder(view);
    }
}
